package ase.eleitweg.server.db;

import java.util.*;
import ase.eleitweg.common.*;

/**
 * This inteface is used to access database-functionality for storing and
 * retrieving users and groups
 * 
 * @author all
 * 
 */
public interface UserGroupDAO {

	/**
	 * @return All users stored in the DB
	 */
	public List<User> getUsers();

	/**
	 * Returns user with given id (if exists), otherwise null
	 * 
	 * @param id
	 * @return
	 */
	public User getUserById(int id);

	/**
	 * @return The list of all groups - also containing their users.
	 */
	public List<Group> getGroups();

	/**
	 * @return Retunrs group with given id (if exists), otherwise null
	 */
	public Group getGroupById(int id);

	/**
	 * Returns all groups of which user u is a member
	 * 
	 * @param u
	 * @return
	 */
	public List<Group> getUsersGroups(User u);

	/**
	 * Returns all users of a given group (if exists), otherwise null
	 * 
	 * @param g
	 * @return
	 */
	public List<User> getUsersOfGroup(Group g);

	/**
	 * Add a new user to the database
	 * 
	 * @param u
	 */
	public void createUser(User u);

	/**
	 * Add a new group to the database. If the Group already has any assigned
	 * users, make sure these users are already in the db before calling this
	 * function!
	 * 
	 * @param g
	 */
	public void createGroup(Group g);

	/**
	 * Adds user u to group g and stores this information in the database. Make
	 * sure that u is already in the db before calling this function.
	 * 
	 * @param g
	 * @param u
	 */
	public void addUser(Group g, User u);

	/**
	 * Updates the information of user u. You cannot update a user that is not
	 * in the database so make sure that the user with the given id exists.
	 * 
	 * @param u
	 */
	public void updateUser(User u);

	/**
	 * Update the information of group g. You cannot update a group that is not
	 * in the database so make sure that the group with the given id exists.
	 * Also make sure that the users of g are already in the database.
	 * @param g
	 */
	public void updateGroup(Group g);

	/**
	 * Delete group g from database
	 * @param g
	 */
	public void deleteGroup(Group g);

	/**
	 * Delete user u from database 
	 * @param u
	 */
	public void deleteUser(User u);
}
